package serverdata.ch.home.www.ResponseClass;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

import serverdata.ch.home.www.server.HttpData;
import serverdata.ch.home.www.server.PreparedInterface;


import android.content.Context;
import android.hardware.SensorManager;

public class SensorManagmentConnection implements PreparedInterface{

	private Context context;
	SensorManager sm;
	
	public SensorManagmentConnection(Context context) {

		this.context = context;
		 sm = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
	}
	
	public void doGet(BufferedReader in, PrintWriter out, HttpData inputHttp) throws IOException  {
		URICoding Uri = new URICoding(inputHttp.getUrl());
		
		switch(Uri.getURI()){
		case ALLSENSOREXISTING:
			new GetAllSensorExistingResponse(out, in, sm, inputHttp);
			break;
		case SENSORVALUES:
			new GetSensorValueResponse(out, in, sm, inputHttp);
			break;
		case INDEX:
			new IndexPage(out, in, context);
			break;					
		case URINOTEXIST:
			new UriNotExistResponse(out, in);
			break;
		}
		
	}

	public void doPost( BufferedReader in, PrintWriter out, HttpData inputHttp) throws IOException{
		doGet(in, out, inputHttp);
	}

	public PreparedInterface getNewInstance() {
		return new SensorManagmentConnection(context);
	}



}
